Shader "Hidden/Fullscreen/BlitCopy"
{
    HLSLINCLUDE

    #pragma vertex Vert

    #pragma target 4.5
    #pragma only_renderers d3d11 ps4 xboxone vulkan metal switch

    #include "Packages/com.unity.render-pipelines.high-definition/Runtime/RenderPipeline/RenderPass/CustomPass/CustomPassCommon.hlsl"

    TEXTURE2D_X(_Source);
    float _SceneViewMode;

    float4 SimpleBlit(Varyings varyings) : SV_Target
    {
        UNITY_SETUP_STEREO_EYE_INDEX_POST_VERTEX(varyings);

        // 为Scene视图优化UV计算
        float2 uv = varyings.positionCS.xy * _ScreenSize.zw;
        if (_SceneViewMode < 0.5) // Game视图
        {
            uv = uv * _RTHandleScale.xy / _DynamicResolutionFullscreenScale.xy * 2;
        }
        else // Scene视图
        {
            uv = uv * _RTHandleScale.xy * 2;
        }
        
        // 简单的双线性采样，让GPU自动处理分辨率变化
        return SAMPLE_TEXTURE2D_X_LOD(_Source, s_linear_clamp_sampler, uv, 0);
    }

    ENDHLSL

    SubShader
    {
        Pass
        {
            Name "Blit Copy"

            ZWrite Off
            ZTest Always
            Blend Off
            Cull Off

            HLSLPROGRAM
                #pragma fragment SimpleBlit
            ENDHLSL
        }
    }
    Fallback Off
} 